package com.qhg.saas_server.Interceptor;

import com.qhg.saas_server.pojo.Comployee;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 *登录拦截器
 */
@Component
public class LoginInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        HttpSession session = request.getSession();
        Comployee comployee = (Comployee) session.getAttribute("comployee");
//        System.out.println(comployee);
        if(comployee==null){//未登录
            System.out.println("员工未登录，拦截该请求");
            return false;
        }return true;
    }
}
